/****************************************************************************
 *  _____       ______  _____
 * |_   _|     |  ____|/ ____|
 *   | |  _ __ | |__  | (___    Institute of Embedded Systems
 *   | | | '_ \|  __|  \___ \   Zürcher Hochschule für Angewandte
 *  _| |_| | | | |____ ____) |  Wissenschaften
 * |_____|_| |_|______|_____/   8401 Winterthur, Switzerland
 *
 ****************************************************************************
 *
 * @version $Rev: 162 $
 * @author  $Author: bacr $
 * @date    $Date: 2013-11-06 09:10:44 +0100 (mer., 06 nov. 2013) $             
 *
 ***************************************************************************/

#ifndef __PTP2_TASK_H__
#define __PTP2_TASK_H__

#include "object.h"

#define PTP2_TASK_NAME_MAX      32

typedef struct ptp2_task_t      ptp2_task_t;

/**
 *
 * @param  ref      reference pointer
 * @param  param    parameter pointer
 * @return true if task executed well, false otherwise
 */
typedef bool (*ptp2_task_execute_fn)(void *, void *);

/**
 * @brief  Task structure
 */
struct ptp2_task_t {
    object_t                obj;
    char                    name[PTP2_TASK_NAME_MAX];   /**< task name */
    ptp2_task_execute_fn    execute;                    /**< task execution function */
    void                   *ref;                        /**< reference pointer pass to task execution function */
    void                   *param;                      /**< parameter pointer pass to task execution function */
};

ptp2_task_t *ptp2_task_new(const char *name, ptp2_task_execute_fn execute, void *ref, void *param);
bool         ptp2_task_init(ptp2_task_t *this, const char *name, ptp2_task_execute_fn execute, void *ref, void *param);

#endif
